package com.ch.forum.dao;

import org.apache.ibatis.annotations.*;

@Mapper
public interface ArtZanHistoryMapper {

    @Insert("insert into t_art_zan_his(art_id,user_id,is_zan) " +
            "values(#{artId},#{userId},#{isZan})")
    int add(@Param("artId")Long artId, @Param("userId")Long userId, @Param("isZan")int isZan);

    @Select("select count(0) from t_art_zan_his where art_id = #{artId} and user_id = #{userId} and is_zan = 1")
    Long findHisIsExist(@Param("artId")Long artId, @Param("userId")Long userId);

    @Select("select count(0) from t_art_zan_his where art_id = #{artId} and user_id = #{userId} and is_zan = 0")
    Long findHisIsExist2(@Param("artId")Long artId, @Param("userId")Long userId);

    @Update("update t_art_zan_his set is_zan = #{isZan} where art_id = #{artId} and user_id = #{userId}")
    int updateIsZan(@Param("isZan")int isZan, @Param("artId")Long artId, @Param("userId")Long userId);
}
